package com.neu.flashmall.product.vo;

import com.neu.flashmall.product.entity.PmsCategory;
import lombok.*;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author 50286
 * 封装前端需要的商品类别信息的实体类
 */
@Data
@Setter
public class PmsCategoryVo {
    private List<PmsCategoryItem> data;

    @Getter
    @Setter
    @AllArgsConstructor
    @NoArgsConstructor
    public static class PmsCategoryItem implements Cloneable{
        private PmsCategory detail;
        private Long id;
        private String name;
        private List<PmsCategoryItem> children;
        private boolean show;

        @Override
        public Object clone() throws CloneNotSupportedException {
            PmsCategoryItem newOne = (PmsCategoryItem) super.clone();
            newOne.setDetail((PmsCategory) this.detail.clone());
            newOne.setChildren(children == null ? new ArrayList<>():new ArrayList<>(this.children));
            return newOne;
        }
    }
}
